  /*global require*/

import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router);

const error = r => require.ensure([], () => r(require('@/views/error/404')), 'error');
const success = r => require.ensure([], () => r(require('@/views/success/view')), 'success');
// 推广注册页
const promoteView = r => require.ensure([], () => r(require('@/views/promote/view')), 'promoteView');
const downloadView = r => require.ensure([], () => r(require('@/views/download/view')), 'downloadView');
// 产品
const process1 = r => require.ensure([], () => r(require('@/views/process/view1')), 'process1');
const process2 = r => require.ensure([], () => r(require('@/views/process/view2')), 'process2');

export default new Router({
  // mode: 'history',
  routes: [
    {
      path: '/',
      name: 'promoteView',
      meta: {auth: false, title: '推广', countTitle: '推广'},
      component: promoteView
    },
    {
      path: '/download',
      name: 'downloadView',
      meta: {auth: false, title: '下载', countTitle: '下载'},
      component: downloadView
    },
    {
      path: '/error',
      meta: {auth: false, title: '错误', countTitle: '错误'},
      name: 'error',
      component: error
    },
    {
      path: '/success',
      meta: {auth: false, title: '申请成功', countTitle: '申请成功'},
      name: 'success',
      component: success
    },
    {
      path: '/process/view1',
      name: 'process1',
      meta: {auth: false, title: '请先完善你的资料', countTitle: ' '},
      component: process1
    },
    {
      path: '/process/view2',
      name: 'process2',
      meta: {auth: false, title: '填写资质信息', countTitle: ' '},
      component: process2
    },
    {
      path: '*',
      meta: {auth: false, title: '错误', countTitle: '错误'},
      redirect: '/error'
    },
  ]
})
